12. Deleting Records
When a record is deleted by the user, FileFlex does not physically remove
the record from the file automatically. Rather, it marks the record as deleted.
This allows your program to "undelete" a record.
When you wish to make these deletions irretrievable, you can either use
the two-step process of physically removing the marked records and compacting
the file to remove unused space or simply zap the records from the file
as documented below.
Because of this complexity, FileFlex includes five functions that deal with
deleting records:
- DBDeleteRecs
- DBRecallRecs
- DBPack
- DBZapRecs
- DBRecordDeleted
Marking Records for Deletion
The DBDeleteRecs function marks a range of records for deletion. It takes
two arguments: a starting record number and an ending record number. The
following function call, then, would mark records 9-15 of the current database
file for later deletion:
put DBDeleteRecs(9,15) into dbResult
Unmarking Delete-marked Records
To unmark one or more records previously marked for deletion, use the DBRecallRecs
function. Like the DBDeleteRecs function, it takes two arguments defining
a range of records previously marked for deletion but not yet deleted. The
records are unmarked and will not be deleted by a subsequent use of the
DBPack function described below. Here's a sample use of this function:
put DBRecallRecs(11,12) into dbResult
Physically Removing Marked Records
To remove all records that are currently marked for deletion and pack the
file to remove unused space resulting from the deletions, use the FileFlex
DBPack function. This function requires no arguments since it operates on
all previously marked records. Its use would appear something like this:
put DBPack() into dbResult
Physically Deleting Records
When you wish to physically remove one or more records from the current
database file in one step, use the DBZapRecs function. It requires two arguments
that define a range of records to be marked for deletion and deleted. In
effect, the DBZapRecs function combines the results of the DBDeleteRecs
and DBPack functions into one operation. Here is a sample of its use:
put DBZapRecs(9,15) into dbResult
Determining if a Record is Deleted
The FileFlex function DBRecordDeleted allows you to determine whether any
given record in a database file is marked for deletion. This function requires
a record number as an argument and returns "Y" if the record is
marked for deletion, or "N" if it is not. For example:
put DBRecordDeleted(39) into recDeleted
[Previous Chapter] [Table of Contents] [Next Chapter]
Copyright (c) 1996 David Gewirtz under license to Component Software Corp.
All rights reserved worldwide.